package member;

import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MemberFactory {
	
	//드라이버를 로딩, Connection정보를 갖고 있음.
	private static SqlSessionFactory factory;
	
	// static을 생성하기위해서 static블럭을 사용함
	static{
		try{
			//xml읽어오기
			Reader reader= Resources.getResourceAsReader("config.xml");
			factory = new SqlSessionFactoryBuilder().build(reader);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
	
	public static SqlSessionFactory getFactory(){
		return factory;
	}
}

/*package member;


import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;


public class MemberFactory {
	
	//SqlSessionFactory 만들기>>driver loading, Connection information
	private static SqlSessionFactory factory;
	
	
	//위에 있는 static을 생성하기 위해 static{}

	static{
		
		try{
			Reader reader =Resources.getResourceAsReader("config.xml");
				
			factory=new SqlSessionFactoryBuilder().build(reader);
					
		}catch(Exception ex){
		ex.printStackTrace();	
		}
		
	}
	
	public static SqlSessionFactory getFactory(){
		return factory;
		
	}
}
*/